/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * Nihongo
 * Copyright (C) Massimiliano Maniscalco 2011, 2012 <massi.neptune@yahoo.com>
 * 
 * Nihongo is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Nihongo is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _ESEMPIO_H_
#define _ESEMPIO_H_

#include <glibmm/ustring.h>
#include <iostream>

using namespace std;

class Esempio
{
	
public:
	Esempio ( const Glib::ustring &str = "" ) :
		_bun ( str ), _gaikokugo ( "" ), _contesto ( "" )
	{}
	inline Esempio ( const Esempio &exmp );
	inline bool operator<( const Esempio &exmp ) const;
	inline bool operator==( const Esempio &exmp ) const;
	inline void set_bun ( const Glib::ustring &str ) { _bun.assign ( str ); }
	inline void set_bun ( const char *cstr );
	inline Glib::ustring get_bun ( void ) const { return _bun; }
	inline void set_gaikokugo ( const Glib::ustring &str ) { _gaikokugo.assign ( str ); }
	inline void set_gaikokugo ( const char *cstr );
	inline Glib::ustring get_gaikokugo ( void ) const { return _gaikokugo; }
	inline void set_contesto ( const Glib::ustring &str ) { _contesto.assign ( str ); }
	inline void set_contesto ( const char *cstr );
	inline Glib::ustring get_contesto ( void ) const { return _contesto; }
	inline void cleanup ( void );
	inline Glib::ustring get_xml_string ( const Glib::ustring &language ) const;

protected:

private:
	Glib::ustring _bun;
	Glib::ustring _gaikokugo;
	Glib::ustring _contesto;

};

inline Esempio::
Esempio ( const Esempio &exmp ) :
	_bun ( exmp._bun ), _gaikokugo ( exmp._gaikokugo ), _contesto ( exmp._contesto )
{}

inline bool Esempio::
operator<( const Esempio &exmp ) const
{
	return _bun.raw () < exmp._bun.raw ();
}

inline bool Esempio::
operator==( const Esempio &exmp ) const
{
	return _bun.raw () == exmp._bun.raw ();
}

inline void Esempio::
set_bun ( const char *cstr )
{
	if ( cstr )
		_bun.assign ( cstr );
}

inline void Esempio::
set_gaikokugo ( const char *cstr )
{
	if ( cstr )
		_gaikokugo.assign ( cstr );
}

inline void Esempio::
set_contesto ( const char *cstr )
{
	if ( cstr )
		_contesto.assign ( cstr );
}

inline void Esempio::
cleanup ( void )
{
	set_bun ( "" );
	set_gaikokugo ( "" );
	set_contesto ( "" );
}

inline Glib::ustring Esempio::
get_xml_string ( const Glib::ustring &language ) const
{
	Glib::ustring str;
	str.append ( Glib::ustring ( "<esempio>\n" ) );
	str.append ( Glib::ustring ( "\t<locutio>" + _bun + "</locutio>\n" ) );
	str.append ( Glib::ustring ( "\t<gaikokugo lang=\"" + language + "\">" + _gaikokugo + "</gaikokugo>\n" ) );
	str.append ( Glib::ustring ( "\t<contesto>" + _contesto + "</contesto>\n" ) );
	str.append ( Glib::ustring ( "</esempio>\n" ) );
	return str;
}

#endif // _ESEMPIO_H_
